//
//  CZFoodDetailViewController.m
//  UISplitViewController练习
//
//  Created by chao on 15/2/28.
//  Copyright (c) 2015年 chao. All rights reserved.
//

#import "CZFoodDetailViewController.h"
#import "CZFood.h"

@interface CZFoodDetailViewController ()
@property (nonatomic, weak) UIWebView *webView;
@end

@implementation CZFoodDetailViewController
- (void)loadView {
    UIWebView *webView = [[UIWebView alloc] init];
    webView.frame = [UIScreen mainScreen].applicationFrame;
    self.view = webView;
    self.webView = webView;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = self.food.name;
    
    NSString *fileName = [NSString stringWithFormat:@"Html/food/%@", self.food.idstr];
    // 加载本地html文件
    NSURL *url = [[NSBundle mainBundle] URLForResource:fileName withExtension:@"html"];
    [self.webView loadRequest:[NSURLRequest requestWithURL:url]];
    
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"关闭" style:UIBarButtonItemStylePlain target:self action:@selector(close)];
}

- (void)close {
    [self dismissViewControllerAnimated:YES completion:nil];
}
@end
